package com.groupbuying.common.service;

import com.groupbuying.common.intercepter.FeignIntercepter;
import com.groupbuying.common.utils.SpringMultipartEncoder;
import feign.Response;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.http.MediaType;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import java.util.List;

/**
 * @anthor wenguoqiang
 * @date: 2019/02/20 16:03
 * @company 够样
 * @des
 **/
@FeignClient(name = "service-file", configuration = {FeignIntercepter.class, SpringMultipartEncoder.class})
public interface FileRpcService {

    /**
     * 下载文件
     * @param fileUuid
     * @return
     */
    @RequestMapping(value = { "/file/rpcDownLoadFile" },  method = {RequestMethod.POST })
    public Response rpcDownLoadFile (@RequestParam("fileUuid")String fileUuid);

    /**
     * 上传文件
     * @param files
     * @param applicationName
     * @return
     */
    @RequestMapping(value = { "/file/rpcUploadFile" },  method = {RequestMethod.POST },consumes = MediaType.MULTIPART_FORM_DATA_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
    public String rpcUploadFile(@RequestPart("files") MultipartFile[] files , @RequestParam("applicationName") String applicationName);

    /**
     * 获取fileUuid集合
     * @param fileGroupKey
     * @return
     */
    @PostMapping("/file/getFileUuids")
    public List<String> getFileUuids(@RequestParam("fileGroupKey") String fileGroupKey);
}
